#
# not_found.py - handler code for pages that were requested but dont exist
#
# Copyright 2008-2009 Autelic Association (http://www.autelic.org)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import cgi

from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db
import os
from google.appengine.ext.webapp import template

class MainPage(webapp.RequestHandler):
  def get(self):

    header_text = 'An error has occurred, please follow the link below to return to the home page'
    url = '/'
    url_linktext = 'Return to home page'

    template_values = {
      'header_text': header_text,
      'url': url,
      'url_linktext': url_linktext,
      }

    # TODO use email class to send an e-mail to admins waning of the application
    # error, using send_mail_to_admins()

    path = os.path.join(os.path.dirname(__file__), 'not_found.html')
    self.response.out.write(template.render(path, template_values))

application = webapp.WSGIApplication(
                                     [('/', MainPage)],
                                     debug=True)

def main():
  run_wsgi_app(application)

if __name__ == "__main__":
  main()
